import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:photo_frame/router/router_context.dart';

class MeItemCell extends StatelessWidget {
  final Widget? leading;
  final Widget? middle;
  final Widget? tailing;
  final String? title;
  final String? routerPath;
  final VoidCallback? action;
  final Map<String, dynamic>? args;

  const MeItemCell({
    this.leading,
    this.routerPath,
    this.tailing,
    this.title,
    this.middle,
    this.args,
    this.action,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return CupertinoButton(
        onPressed: () {
          if (routerPath != null) {
            ARouter.instance.pagePush(routerPath!, arguments: args);
          }
          if (action != null) {
            action!();
          }
        },
        padding: EdgeInsets.zero,
        child: Container(
          height: 60,
          margin: EdgeInsets.only(top: 12),
          padding: EdgeInsets.only(left: 20, right: 20),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10),
            color: Colors.white,
          ),
          child: Row(
            children: [
              leading != null
                  ? Padding(padding: EdgeInsets.only(right: 10), child: leading)
                  : SizedBox(width: 0),
              Expanded(
                  child: middle ??
                      Text(
                        title ?? "",
                        style:
                            TextStyle(fontSize: 14, color: Color(0xff555555)),
                      )),
              tailing != null
                  ? Padding(
                      padding: EdgeInsets.only(left: 10),
                      child: tailing,
                    )
                  : SizedBox(width: 0)
            ],
          ),
        ));
  }
}

class MeItemArrow extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Image.asset(
      "images/icon_right_arrow.png",
      width: 10,
      height: 20,
    );
  }
}

class MeItemIcon extends StatelessWidget {
  final String path;
  MeItemIcon(this.path, {super.key});

  @override
  Widget build(BuildContext context) {
    return Image.asset(
      path,
      width: 20,
      height: 20,
    );
  }
}
